<?php
/**
 * @author hua <css3@qq.com>
 */

namespace console\controllers;

use common\models\User;
use yii\console\Controller;
use yii\helpers\Console;

class ToolController extends Controller
{
    public function actionCreateUser($username, $email, $password)
    {
        $user = new User();
        $user->username = $username;
        $user->email = $email;
        $user->setPassword($password);
        $user->generateAuthKey();
        if ($user->save()) {
            $this->stdout("User create success\n", Console::FG_GREEN);
        } else {
            $this->stdout("User create fail\n", Console::FG_RED);
        }
    }
}